<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>demo</title>
<link rel="stylesheet" type="text/css" href="css/ye.check.css" />
<script type="text/javascript" src="../jquery.js"></script>
<script type="text/javascript" src="../js/ye.check.js"></script>
<style type="text/css">
#form1 li {
	height: 45px;
	list-style: none;
}

.b {
	width: 30%;
	display: block;
	text-align: right;
	float: left;
}

span {
	display: inline-block;
	text-align: left;
	float: left;
}
</style>
</head>
<body>
	<div>
		<form method="post" id="form1">
			<ul>
				<li><label class="b">用户名：</label> <span><input type="text"
						name="username" id="username" rule="require" /></span></li>
				<li><label class="b">密码：</label> <span><input type="text"
						name="password" id="password" rule="require" /></span></li>
				<li><label class="b">手机号码：</label> <span><input type="text"
						name="mobile" id="mobile" rule="mobile" /></span></li>
				<li><label class="b">身份证号码：</label> <span><input type="text"
						name="idcard" id="idcard" rule="idcard" /></span></li>
				<li><label class="b">选项：</label> <span><input type="checkbox" id="t-option" onclick="setMore(this)"  /></span>
				</li>
				</ul>

				<ul id="moreBox" >
				<li><label class="b">性别：</label> <span> <input type="radio"
						name="sex" rule="radio" />男 <input type="radio" name="sex"
						rule="radio" />女
				</span></li>
				<li><label class="b">年龄：</label> <span><input type="text"
						name="age" id="age" check-conf="{agestart:18,ageend:60}" /></span></li>
				<li><label class="b">ip：</label> <span><input type="text"
						name="ip" id="ip" /></span></li>
				</ul>
				<label class="b">&nbsp;</label> <span> <input type="button"
						id="post" value="提交" onclick="save();" />
				</span>
		</form>
	</div>
	<script type="text/javascript">
	function setMore(dom){
		if(dom.checked){
			self.setOption(function(option){
				option.sex[3] = true;
				option.age[3] = true;
				option.ip[3] = true;
				return option;
			})
			self.do_blur();
		}else{
			self.setOption(function(option){
				option.sex[3] = false;
				option.age[3] = false;
				option.ip[3] = false;
				return option;
			});
			self.do_blur();
		}
	}
		var option = {
				'username' : [ 'require', '不能为空', '&nbsp;' ],
				'password' : [ 'require', '不能为空', '&nbsp;' ],
				'mobile' : [ 'mobile', '不能为空', '&nbsp;' ],
				'idcard' : [ 'idcard', '不能为空', '&nbsp;' ],
				'sex' : [ 'radio', '不能为空', '&nbsp;', false],
				'age' : [ 'age', '年龄格式错误', '&nbsp;', false],
				'ip' : [ 'ip', '错误', '&nbsp;', false ]
		};

		var self = ye.check(option).do_blur();

		function save() {
			var self = ye.check(option).do_post({
				msg : {
					right : 'dright',
					error : 'derr'
				},
				form : ye.g('form1'),
				btn : {
					name : 'post',
					text : 'load...'
				}
			});
		}
	</script>
</body>
</html>
